package com.hhss.qishi.config.pagehelper;

import org.hibernate.validator.constraints.Range;

/**
 * @author hhss
 * @date 2019年3月31日 
 */
public class PageQO<T> {
	/**
     * 按创建时间倒序排序
     */
    public static final String ORDER_BY_CREATE_TIME_DESC = "create_time desc";

    @Range(min = 1, max = Integer.MAX_VALUE)
    private int pageNum = 1;

    @Range(min = 1, max = Integer.MAX_VALUE)
    private int pageSize = 10;

    private String orderBy;

    private T condition;

    public PageQO(int pageNum, int pageSize) {
    	super();
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public int getOffset() {
        return (this.pageNum - 1) * this.pageSize;
    }

	/**
	 * @return the pageNum
	 */
	public int getPageNum() {
		return pageNum;
	}

	/**
	 * @param pageNum the pageNum to set
	 */
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @return the orderBy
	 */
	public String getOrderBy() {
		return orderBy;
	}

	/**
	 * @param orderBy the orderBy to set
	 */
	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}

	/**
	 * @return the condition
	 */
	public T getCondition() {
		return condition;
	}

	/**
	 * @param condition the condition to set
	 */
	public void setCondition(T condition) {
		this.condition = condition;
	}

	@Override
	public String toString() {
		return "PageQO [pageNum=" + pageNum + ", pageSize=" + pageSize + ", orderBy=" + orderBy + ", condition="
				+ condition + "]";
	}

}
